package org.aeon.heroicsagatextedition.game;

import org.aeon.heroicsagatextedition.exception.GameException;

import java.lang.reflect.InvocationTargetException;

/**
 * @projectName: HeroicSagaTextEdition
 * @package: org.aeon.heroicsagatextedition.game
 * @className: GameFacade
 * @author: MissingAeon
 * @date: 2023/12/22 14:15
 * @description: 游戏外观，用于提供对外接口
 */
public class GameFacade {
    private final Game game;
    private final GameMenu gameMenu;
    private final GameState gameState;

    public GameFacade() {
        game = Game.getGame();
        gameMenu = GameMenu.getGameMenu();
        gameState = GameState.getGameState();
    }

    // 开始游戏
    public void startUp() {
        gameState.setState(1);
        while (true) {
            try {
                gameMenu.displayMenu(game.getClass()).invoke(game);
            } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
                throw new GameException("游戏错误！");
            }
        }
        // gameState.setState(0);
    }

}
